
#ifndef __COMMH_MSG_H__
#define __COMMH_MSG_H__

#include "CTMsgBase.h"
#include "CTCodeUpdate.h"
#include "commclass.h"
#include "CTKeyValue.h"

enum
{
    EMAX_SQLLEN = 40960,     ///< SQL语句的最大长度
    EMAX_RESULTMSG = 1024,      ///最大错误描述
};

/** 消息ID定义 */
enum enumMsgID
{
    // 1000~1999 是client发向mainsvr的消息, 程序内会根据这个段来检查安全性
    //注意新增跟前台通信的命令ID时, 需要使用奇数
    ID_MAIN_MIN                         = 1000,
    ID_MAIN_MAX                         = 1999,
    ID_MAIN_NOTIFY                      = ID_MAIN_MIN + 1,  //消息下发
    ID_MAIN_LOGIN                       = ID_MAIN_MIN + 3,
    ID_MAIN_GET_USER_INFO               = ID_MAIN_MIN + 5,
    ID_MAIN_GET_MAP_INFO                = ID_MAIN_MIN + 7,
    ID_MAIN_MAP_MOVE                    = ID_MAIN_MIN + 9,
    ID_MAIN_LOGOUT                      = ID_MAIN_MIN + 11,
    ID_MAIN_GET_TASK_LIST               = ID_MAIN_MIN + 13,
    ID_MAIN_ACCEPT_TASK                 = ID_MAIN_MIN + 15,
    ID_MAIN_COMMIT_TASK                 = ID_MAIN_MIN + 17,
    ID_MAIN_INIT_USER_INFO              = ID_MAIN_MIN + 19,
    ID_MAIN_PARTNER                     = ID_MAIN_MIN + 21,
    ID_MAIN_GET_USER_STORAGE_INFO       = ID_MAIN_MIN + 23,
    ID_MAIN_GRID_BASE_INFO              = ID_MAIN_MIN + 25,
    ID_MAIN_GET_ITEM_DETAIL_INFO        = ID_MAIN_MIN + 27,
    ID_MAIN_EQUIP_ROLE                  = ID_MAIN_MIN + 29,
    ID_MAIN_PICK_UP_ITEM                = ID_MAIN_MIN + 31,
    ID_MAIN_DISCARD_ITEM                = ID_MAIN_MIN + 33,
    ID_MAIN_SWAP_ITEM_POS               = ID_MAIN_MIN + 35,
    ID_MAIN_SORT_STORAGE                = ID_MAIN_MIN + 37,
    ID_MAIN_MERGE_BAGTOWARE             = ID_MAIN_MIN + 39,
    ID_MAIN_UNLOCK_GRID                 = ID_MAIN_MIN + 41,
    ID_MAIN_USER_OPT                    = ID_MAIN_MIN + 43, //用来感知用户操作
    ID_MAIN_GOTO_INSTANCE               = ID_MAIN_MIN + 45,
    ID_MAIN_ATK_INSTANCE                = ID_MAIN_MIN + 47,
    ID_MAIN_LEAVE_INSTANCE              = ID_MAIN_MIN + 49,
    ID_MAIN_SHOP_GET_INFO               = ID_MAIN_MIN + 51,
    ID_MAIN_SHOP_BUY                    = ID_MAIN_MIN + 53,
    ID_MAIN_SHOP_SELL                   = ID_MAIN_MIN + 55,
    ID_MAIN_SWEEP_INSTANCE              = ID_MAIN_MIN + 57, //副本扫荡
    ID_MAIN_GET_INSTANCE_INFO           = ID_MAIN_MIN + 59, //获取副本信息
    ID_MAIN_REFRESH_SHOP                = ID_MAIN_MIN + 61, //刷新神秘商店
    ID_MAIN_MATRIX                      = ID_MAIN_MIN + 63, //阵形操作

    ID_MAIN_CARD                        = ID_MAIN_MIN + 65, //卡片基础协议
    ID_MAIN_CARD_DIVINE_INFO            = ID_MAIN_MIN + 67, //卡片:获取占卜信息
    ID_MAIN_CARD_TURN_OVER_CARD         = ID_MAIN_MIN + 69, //卡片:翻牌
    ID_MAIN_CARD_ROLE                   = ID_MAIN_MIN + 71, //卡片:穿、脱
    ID_MAIN_CARD_VORTEX                 = ID_MAIN_MIN + 73, //卡片：命运漩涡协议
    ID_MAIN_CARD_COMB                   = ID_MAIN_MIN + 75, //卡片：合成

    ID_MAIN_GET_INS_WIN_BONUS           = ID_MAIN_MIN + 77, //领取副本胜利奖励
    ID_MAIN_INS_OPT                     = ID_MAIN_MIN + 79, //副本通用操作

    ID_MAIN_EQUIP_STRENGTH              = ID_MAIN_MIN + 81,   //装备强化
    ID_MAIN_EQUIP_MAKE_INFO             = ID_MAIN_MIN + 83,   //请求装备信息
    ID_MAIN_EQUIP_MAKE                  = ID_MAIN_MIN + 85,   //装备合成
    ID_MAIN_EQUIP_CRYSTAL               = ID_MAIN_MIN + 87,   //魔晶操作
    ID_MAIN_WORLD_BOSS                  = ID_MAIN_MIN + 89,   //世界BOSS
    ID_MAIN_SOUL                        = ID_MAIN_MIN + 91,   //魂器协议
    ID_MAIN_ACADEMY_BOSS                = ID_MAIN_MIN + 93,   //学院BOSS
    ID_MAIN_FRIEND                      = ID_MAIN_MIN + 95,   //好友协议
    ID_MAIN_TIPS                        = ID_MAIN_MIN + 97,   //用于消息返回
    ID_MAIN_SEND_MSG_TO_FRIEND          = ID_MAIN_MIN + 99,   //向好友发送消息

    ID_MAIN_GARDEN                      = ID_MAIN_MIN + 111,   //花园协议

    ID_MAIN_ALCHEMY                     = ID_MAIN_MIN + 113,   //练金
    ID_MAIN_ENERGY                      = ID_MAIN_MIN + 115,   //精力系统

    ID_MAIN_MINE_CRYSTAL                = ID_MAIN_MIN + 117,   //魔晶开采
    ID_MAIN_INHERIT_DRUG_INFO           = ID_MAIN_MIN + 119,   //魔药传承信息
    ID_MAIN_ROLE_DURG_INFO              = ID_MAIN_MIN + 121,   //请求角色的魔药信息
    ID_MAIN_DURG_MAKE_INFO              = ID_MAIN_MIN + 123,   //请求魔药制作信息
    ID_MAIN_MAKE_DRUG                   = ID_MAIN_MIN + 125,   //魔药合成/提纯
    ID_MAIN_INHERIT_DRUG                = ID_MAIN_MIN + 127,   //魔药传承

    ID_MAIN_ARENA                       = ID_MAIN_MIN + 129,   //竞技场

    ID_MAIN_CHAT                        = ID_MAIN_MIN + 131,   //聊天

    ID_MAIN_ATTR                        = ID_MAIN_MIN + 133,   //角色和伙伴属性
    ID_MAIN_LESSON                      = ID_MAIN_MIN + 135,   //上课系统

    ID_MAIN_ZONE_CLAN_INFO              = ID_MAIN_MIN + 141,   //请求本区家族信息
    ID_MAIN_USER_CLAN_INFO              = ID_MAIN_MIN + 143,   //请求用户相关的家族信息
    ID_MAIN_CLAN_OPER                   = ID_MAIN_MIN + 145,   //请求家族操作

    ID_MAIN_OTHER_INFO                  = ID_MAIN_MIN + 149,    //获取其他人的信息

    ID_MAIN_GET_DEFEND_INFO             = ID_MAIN_MIN + 151,   //request defend valid info
    ID_MAIN_COMMIT_DEFEND_INFO          = ID_MAIN_MIN + 153,   //commit defend valid info
    ID_MAIN_COMMIT_DEFEND_OTHER         = ID_MAIN_MIN + 155,   //commit defend other info

    ID_MAIN_CHECK_ROLENAME              = ID_MAIN_MIN + 161,   //检查昵称

    //日常任务,每日任务消息id
    ID_MAIN_GET_DAILY_TASK              = ID_MAIN_MIN + 163,    //请求每日任务列表
    ID_MAIN_FIND_YESTERDAY_TASK         = ID_MAIN_MIN + 165,    //找回昨日任务
    ID_MAIN_OPEN_TBOX                   = ID_MAIN_MIN + 167,    //开启宝箱

    ID_MAIN_TREASURE                    = ID_MAIN_MIN + 169,   //秘宝系统

    ID_MAIN_INS_DETAIL_INFO             = ID_MAIN_MIN + 175,    //副本详细信息
    ID_MAIN_INS_SECRET                  = ID_MAIN_MIN + 177,    //秘境功能

    ID_MAIN_BAG_OPT                     = ID_MAIN_MIN + 179,    //操作背包格子

    ID_MAIN_ONLINE_GIFT                 = ID_MAIN_MIN + 181,    //在线礼包
    ID_MAIN_GIFT_OPT                    = ID_MAIN_MIN + 183,    //礼包操作

    //宠物消息id
    ID_MAIN_GET_PET_INFO                = ID_MAIN_MIN + 185,    //请求宠物信息
    ID_MAIN_PET_TRAIN                   = ID_MAIN_MIN + 187,    //宠物培养
    ID_MAIN_PET_OTHER                   = ID_MAIN_MIN + 189,    //宠物其他请求信息

    ID_MAIN_ACT_OPT                     = ID_MAIN_MIN + 191,    //活动系统

    ID_MAIN_MUSE_OPT                    = ID_MAIN_MIN + 193,    //冥想系统

    ID_MAIN_MOUNT_OPT                   = ID_MAIN_MIN + 195,    //坐骑系统

    ID_MAIN_COOLING_OPT                 = ID_MAIN_MIN + 197,    //冷却通用操作

    ID_MAIN_FASHION_OPT                 = ID_MAIN_MIN + 199,    //时装操作

    ID_MAIN_CLAN_BATTLE                 = ID_MAIN_MIN + 201,    //家族战

    ID_MAIN_ACADEMY_OPT                 = ID_MAIN_MIN + 203,    //学院

    //vip
    ID_MAIN_GET_VIP_INFO                = ID_MAIN_MIN + 205,    //请求vip信息
    ID_MAIN_VIP_GIFT_INFO               = ID_MAIN_MIN + 207,    //获取vip礼包信息
    ID_MAIN_OPEN_VIP_GIFT               = ID_MAIN_MIN + 209,    //领取礼包

    ID_MAIN_ENEMY_ATK_CITY              = ID_MAIN_MIN + 211,    //怪物攻城战

    ID_MAIN_MAGIC_DOOR                  = ID_MAIN_MIN + 213,    //家族魔界门

    ID_MAIN_FAMILY_DICE                 = ID_MAIN_MIN + 215,    //家族闯关

    ID_MAIN_NOTIFY_DROP_ITEM            = ID_MAIN_MIN + 217,    //物品掉落下发

    ID_MAIN_AUCTION                     = ID_MAIN_MIN + 219,    //拍卖会

    ID_MAIN_CLAN_TREE                   = ID_MAIN_MIN + 221,    //家族种树

    ID_MAIN_WISH                        = ID_MAIN_MIN + 223,    //许愿池

    ID_MAIN_SPLENDID_ACT                = ID_MAIN_MIN + 225,    //精彩活动

    ID_MAIN_USER_GUIDE                  = ID_MAIN_MIN + 227,    //用户指引

    ID_MAIN_RANK                        = ID_MAIN_MIN + 229,    //排行榜

    ID_MAIN_GET_MULTI_TENCENT_INFO      = ID_MAIN_MIN + 231,    //批量获取平台数据

    ID_MAIN_QQ_MALL                     = ID_MAIN_MIN + 233,    //腾讯平台买物品

    ID_MAIN_YELLOW_GIFT                 = ID_MAIN_MIN + 235,    //黄钻特权

    ID_MAIN_FRIEND_TREE                 = ID_MAIN_MIN + 237,    //好友经验树

    ID_MAIN_PYRAMID_ACT                 = ID_MAIN_MIN + 239,    //金字塔

    ID_MAIN_LOGIN_GOLD                  = ID_MAIN_MIN + 241,    //登陆奖励金币

    ID_MAIN_CLAN_DIAL                   = ID_MAIN_MIN + 243,    //家族转盘

    ID_MAIN_DAY_SIGN                    = ID_MAIN_MIN + 245,    //每日签到

    ID_MAIN_DAY_WISH                    = ID_MAIN_MIN + 247,    //每日许愿

    ID_MAIN_GROW_FUND                   = ID_MAIN_MIN + 249,    //成长基金

    ID_MAIN_PAY_BACK                    = ID_MAIN_MIN + 251,    //消费返利

    ID_MAIN_NEWBIE_TASK                 = ID_MAIN_MIN + 253,    //新手目标

    ID_MAIN_FIGHT_FOR_BOX               = ID_MAIN_MIN + 255,    //宝箱争夺

    ID_MAIN_QQ_FRIEND                   = ID_MAIN_MIN + 257,    //邀请QQ好友

    ID_MAIN_EQUIP_REFINE                = ID_MAIN_MIN + 259,    //装备洗练

    ID_MAIN_EQUIP_BLESS                 = ID_MAIN_MIN + 261,    //装备祝福

    ID_MAIN_FIGHT_END                   = ID_MAIN_MIN + 263,    //一战到底

    ID_MAIN_AWARD_TASK                  = ID_MAIN_MIN + 265,    //悬赏令任务

    ID_MAIN_ACA_CUP                     = ID_MAIN_MIN + 267,    //学院杯

    ID_MAIN_NEWZONE_SALES               = ID_MAIN_MIN + 269,    //开服特卖

    ID_MAIN_MANOR_BATTLE                = ID_MAIN_MIN + 271,    //领地战

    ID_MAIN_REWARD_BACK                 = ID_MAIN_MIN + 273,    //奖励找回

    ID_MAIN_LOGIN_REWARD                = ID_MAIN_MIN + 275,    //登录奖励

    ID_MAIN_ACT_STORAGE                 = ID_MAIN_MIN + 277,    //活动扩展存储

	ID_MAIN_PARTNER_INFO				= ID_MAIN_MIN + 279,	//获得主角伙伴信息
    //注意新增跟前台通信的命令ID时, 需要使用奇数

    // 2000~2099 是mainsvr发向dbsvr的消息
    ID_MAINDB_MIN                       = 2000,
    ID_MAINDB_MAX                       = 2099,
    ID_MAINDB_UPDATEDATA                = ID_MAINDB_MIN + 0,
    ID_MAINDB_SELECTDATA                = ID_MAINDB_MIN + 1,
    ID_MAINDB_OSS                       = ID_MAINDB_MIN + 2,

    // 2100~2199 是mainsvr发向apisvr的消息
    ID_MAINAPI_MIN                       = 2100,
    ID_MAINAPI_MAX                       = 2199,
    ID_MAINAPI_TAPI                      = ID_MAINAPI_MIN + 1, //腾讯open api接口

    // 3000~3999 dbsvr->mpsvr
    ID_DBSVR_MIN                    = 3000,
    ID_DBSVR_MAX                    = 3999,
    ID_DB_SQL                       = ID_DBSVR_MIN + 0,
    ID_DB_ANS                       = ID_DBSVR_MIN + 1,
    ID_DB_INNER_UPDATEDATA          = ID_DBSVR_MIN + 2,

    // 4000~4999 mainsvr inner
    ID_MAIN_INNER_MIN               = 4000,
    ID_MAIN_INNER_MAX               = 4999,
    ID_MAIN_INNER_DROP_ITEM         = ID_MAIN_INNER_MIN + 0,    //掉落物品
    ID_MAIN_INNER_MAINCTRL_INIT_DATA = ID_MAIN_INNER_MIN + 1,    //用于mainctrl启动时初始化数据
    ID_MAIN_INNER_CLAN_BONUS         = ID_MAIN_INNER_MIN + 2,    //分配家族奖励
    ID_MAIN_INNER_ENEMY_ATK_CITY_BONUS = ID_MAIN_INNER_MIN + 3,  //怪物攻城战奖励
    ID_MAIN_INNER_SEND_TIPS         = ID_MAIN_INNER_MIN + 4,      //发送TIPS
    ID_MAIN_INNER_SPLENDID_ACT_CLAN_RANK = ID_MAIN_INNER_MIN + 5, //全服家族排名活动结算
    ID_MAIN_INNER_TREE_BONUS         = ID_MAIN_INNER_MIN + 6,     //家族神树结算(浇水次数、根据神树总等级的全员奖励)
    ID_MAIN_INNER_DROP_TO_EXSPACE    = ID_MAIN_INNER_MIN + 7,     //存放背包中无法存入的物品
    ID_MAIN_INNER_SEND_GOLD          = ID_MAIN_INNER_MIN + 8,     //购买金币后发货
    ID_MAIN_INNER_UPDATE_SNS         = ID_MAIN_INNER_MIN + 9,     //更新玩家SNS数据
    ID_MAIN_INNER_DELETE_CLAN        = ID_MAIN_INNER_MIN + 10,    //解散家族
    ID_MAIN_INNER_AUCTION_PAYBACK    = ID_MAIN_INNER_MIN + 11,    //拍卖会退款
    ID_MAIN_INNER_TREE_RANK          = ID_MAIN_INNER_MIN + 12,    //家族神树排行榜
    ID_MAIN_INNER_INIT_ONLINE_USER   = ID_MAIN_INNER_MIN + 13,    //初始化在线数据,主要用于重启服务器后恢复在线状态
    ID_MAIN_INNER_GET_PLAYER_ONLINE_DATA   = ID_MAIN_INNER_MIN + 14,    //准备在线数据
    ID_MAIN_INNER_QQ_FRIEND          = ID_MAIN_INNER_MIN + 15,    //QQ好友邀请内部命令
    ID_MAIN_INNER_DICE_BONUS         = ID_MAIN_INNER_MIN + 16,    //家族闯关奖励
    ID_MAIN_INNER_FIGHT_END          = ID_MAIN_INNER_MIN + 17,    //一战到底活动
    ID_MAIN_INNER_SPLENDID_GOLD_CARD = ID_MAIN_INNER_MIN + 18,    //金秋猎金排行榜结算
    ID_MAIN_INNER_GM_SEND_GIFT       = ID_MAIN_INNER_MIN + 19,    //批量发送礼包
    ID_MAIN_INNER_ACT_TITLE          = ID_MAIN_INNER_MIN + 20,    //主动下发活动以及称号
    ID_MAIN_INNER_USER_LOGIN         = ID_MAIN_INNER_MIN + 21,    //角色登录
    ID_MAIN_INNER_ACA_CUP_FIRST_ROUND = ID_MAIN_INNER_MIN + 22,   //学院杯淘汰赛(一轮)
    ID_MAIN_INNER_PVP_BATTLE         = ID_MAIN_INNER_MIN + 23,     //PVP战斗
    ID_MAIN_INNER_ACA_CUP_SECOND_ROUND = ID_MAIN_INNER_MIN + 24,  //学院杯决赛(一轮)
    ID_MAIN_INNER_ACA_CUP_SEND_GUESS_BONUS = ID_MAIN_INNER_MIN + 25, //发放竞猜奖励
    ID_MAIN_INNER_MARKET             = ID_MAIN_INNER_MIN + 26,      //任务集市
    ID_MAIN_INNER_MANOR_BATTLE       = ID_MAIN_INNER_MIN + 27,      //领地战
    ID_MAIN_INNER_CHECK_NAME         = ID_MAIN_INNER_MIN + 28,      //检查昵称是否合法
    ID_MAIN_INNER_CREATE_USER        = ID_MAIN_INNER_MIN + 29,     //创建角色

    // 5000~5999 内部protobuf发送gm指令
    ID_MAIN_GM_MIN                   = 5000,
    ID_MAIN_GM_MAX                   = 5999,
    ID_MAIN_GM_PLAYER                = ID_MAIN_GM_MIN + 0,        //针对某个在线角色
    ID_MAIN_GM_OFFICE                = ID_MAIN_GM_MIN + 1,        //官方GM操作
    ID_MAIN_GM_CREATE_USERS          = ID_MAIN_GM_MIN + 2,        //创建角色

    //6000~6999 apisvr -> mpsvr
    ID_INTER_API_MIN                 = 6000,
    ID_INTER_API_MAX                 = 6999,
    ID_INTER_API_TENCENT             = ID_INTER_API_MIN + 1,        //腾讯平台接口
};

enum ENUM_GM_PLAYER_SUB_CMD
{
    ID_GM_PLAYER_SUB_GET_HELP               = 0,            //获取帮助信息
    ID_GM_PLAYER_SUB_INFO_TOKEN             = 1,            //通过token获取角色基本信息
    ID_GM_PLAYER_SUB_INFO_GID               = 2,            //通过GID获取角色基本信息
    ID_GM_PLAYER_SUB_ADD_MONEY              = 3,            //修改角色金钱
    ID_GM_PLAYER_SUB_ADD_REPU               = 4,            //修改角色声望
    ID_GM_PLAYER_SUB_ACT_PARTNER            = 5,            //获取激活伙伴列表
    ID_GM_PLAYER_SUB_LIST_PARTNER           = 6,            //获取历史伙伴列表
    ID_GM_PLAYER_SUB_CHG_PARTNER_FAVOR      = 7,            //修改伙伴好感度
    ID_GM_PLAYER_SUB_ADD_LEVEL              = 8,            //修改角色等级
    ID_GM_PLAYER_SUB_ADD_EXP                = 9,            //修改角色经验
    ID_GM_PLAYER_SUB_ADD_HUNLI              = 10,           //修改角色魂力
    ID_GM_MAINCTRL_OFFSET_TIME              = 11,           //偏移时间
    ID_GM_INSTANCE_FULL                     = 12,           //设置副本全打开
    ID_GM_PLAYER_SUB_ADD_ITEM               = 13,           //在背包中增加物品
    ID_GM_ADD_GARDEN_DATA                   = 14,           //增加花园数据
    ID_GM_PLAYER_SUB_SET_FINISH_TASK        = 15,           //set task finished with taskid
    ID_GM_PLAYER_SUB_SET_ACADMY             = 16,           //设置角色的学院
    ID_GM_PLAYER_SUB_GET_MATRIX             = 17,           //获取阵形列表
    ID_GM_PLAYER_SUB_ADD_FATE_FORCE         = 18,           //增加命运之力
    ID_GM_PLAYER_SUB_DEFEND_ONLINE          = 19,           //设置防沉迷在线时间
    ID_GM_PLAYER_SUB_DEFEND_OFFLINE         = 20,           //设置防沉迷离线时间
    ID_GM_PLAYER_SUB_KILL_ENEMY             = 21,           //杀怪
    ID_GM_PLAYER_SUB_FINISH_INSTANCE        = 22,           //通关
    ID_GM_PLAYER_SUB_CHG_PARTNER_LEVEL      = 23,           //修改伙伴等级
    ID_GM_PLAYER_SUB_CHG_PARTNER_EXP        = 24,           //修改伙伴经验
    ID_GM_PLAYER_SUB_ROLE_ATTR              = 25,           //查看角色属性
    ID_GM_PLAYER_SUB_PARTNER_ATTR           = 26,           //查看伙伴属性
    ID_GM_PLAYER_SUB_SEND_INNER_CMD         = 27,           //内部工厂命令
    ID_GM_PLAYER_SUB_SET_VIP_LEVEL          = 28,           //设置VIP等级
    ID_GM_PLAYER_SUB_GET_TREASURE           = 29,           //查看角色秘宝
    ID_GM_PLAYER_SUB_SET_TREASURE           = 30,           //设置角色秘宝
    ID_GM_PLAYER_SUB_SET_SPIRIT             = 31,           //设置角色灵力
    ID_GM_PLAYER_SUB_FLUSH_ARENA_HERO_LIST  = 32,           //刷新竞技场英雄榜]
    ID_GM_PLAYER_SUB_SET_ENERGY             = 33,           //设置精力
    ID_GM_PLAYER_SUB_ADD_MUSEUM_SWEEP_COUNT = 34,           //增加博物馆扫荡次数
    ID_GM_PLAYER_SUB_GET_STATUS             = 35,           //查看角色状态信息
    ID_GM_PLAYER_SUB_GET_WORLD_BOSS_RANK    = 36,           //查看世界BOSS排名榜
    ID_GM_PLAYER_SUB_GET_ACT_STATUS         = 37,           //查看活动运行时状态
    ID_GM_PLAYER_SUB_RESET_ELITE_COUNT      = 38,           //重置精英副本购买数量
    ID_GM_PLAYER_SUB_RESET_SECRET_COUNT     = 39,           //重置秘境副本购买数量
    ID_GM_PLAYER_SUB_SET_DAILY_TASK         = 40,           //设置每日任务的活跃度
    ID_GM_PLAYER_SUB_OPEN_ENEMY_ATK_CITY    = 41,           //开启怪物攻城战
    ID_GM_PLAYER_SUB_ADD_STATUS             = 42,           //修改角色状态信息
    ID_GM_PLAYER_SUB_ADD_CARD               = 43,           //增加卡片
    ID_GM_PLAYER_SUB_ADD_CLAN_ITEM          = 44,           //增加家族物品
    ID_GM_PLAYER_SUB_SET_PET_EXPER          = 45,           //调整宠物经验等级
    ID_GM_PLAYER_SUB_SET_ACT_STATUS         = 46,           //设置活动运行时状态(1表示强制开启 0表示强制关闭)
    ID_GM_PLAYER_SUB_SET_DAILY_TASK_FINISH  = 47,           //设置某个每日任务完成
    ID_GM_PLAYER_SUB_TEST                   = 48,           //测试用
    ID_GM_PLAYER_SUB_ADD_BONUS_GIFT         = 49,           //添加奖励礼包
    ID_GM_PLAYER_SUB_SET_SYSOPEN            = 50,           //设置系统开放
    ID_GM_PLAYER_SUB_CLEAR_LES              = 51,           //清理上课次数
    ID_GM_PLAYER_SUB_GET_ACADEMY_BOSS_INFO  = 52,           //查看学院BOSS信息
    ID_GM_PLAYER_SUB_CLEAR_CLAN_BATTLE_DATA = 53,           //清理家族战数据
    ID_GM_PLAYER_SUB_GET_MAGIC_DOOR         = 54,           //查看魔界传送门信息
    ID_GM_PLAYER_SUB_BUY_GOLD               = 55,           //充值
    ID_GM_PLAYER_SUB_SET_BOSS_WORLD_LEVEL   = 56,           //修改部分活动世界等级
    ID_GM_PLAYER_SUB_SET_BOSS_MONSTER_HP    = 57,           //修改部分活动怪物血量
    ID_GM_PLAYER_SUB_DROP_TITLE             = 58,           //增加称号
    ID_GM_PLAYER_SUB_CREATE_USERS           = 59,           //创建角色
    ID_GM_PLAYER_SUB_SYS_OPEN_TEST          = 60,           //will测试用
    ID_GM_PLAYER_SUB_SYS_RESET_GOLD_DIVINE  = 61,           //重置金币占卜次数
    ID_GM_PLAYER_SUB_SYS_EXSPACE_TEST       = 62,           //物品掉落测试
    ID_GM_PLAYER_SUB_GET_SYSTEM_NOTICE      = 63,           //查看活动系统提示
    ID_GM_PLAYER_SUB_SYS_RESET_CLAN_DAIL    = 64,           //重置家族转盘次数
    ID_GM_PLAYER_SUB_RESET_PYRAMID          = 65,           //初始化金字塔
    ID_GM_PLAYER_SUB_BUY_GROW_FUND          = 66,           //购买成长基金
    ID_GM_PLAYER_SUB_SET_BOX_BEGIN          = 67,           //开启宝箱争夺
    ID_GM_PLAYER_SUB_BUY_GOODS              = 68,           //模拟购买物品
    ID_GM_PLAYER_SUB_SET_MOUNT_SOUL         = 69,           //增加坐骑魂力
    ID_GM_PLAYER_SUB_SET_CHANGE_BOX_POINT   = 70,           //修改宝箱争夺分数
    ID_GM_PLAYER_SUB_CREATE_SUPER_TEAM      = 71,           //创建超级队伍
    ID_GM_PLAYER_SUB_GET_ACT_INFO           = 72,           //查看指定活动数据
    ID_GM_PLAYER_SUB_NEWSALES               = 73,           //新服特卖
    ID_GM_PLAYER_SUB_ACA_CUP                = 74,           //学院杯
    ID_GM_PLAYER_SUB_MARKET                 = 75,           //任务集市
    ID_GM_PLAYER_SUB_REWARD_BACK            = 76,           //奖励找回
    ID_GM_PLAYER_SUB_ROCK_SCORE             = 77,           //摇摇乐修改积分
};

enum ENUM_GM_OFFICE_SUB_CMD
{
    ID_GM_OFFICE_SUB_GET_HELP               =  0,            //获取帮助信息
    ID_GM_OFFICE_SUB_FREEZE_LOGIN           =  1,            //以天为单位冻结玩家登录
    ID_GM_OFFICE_SUB_UNFREEZE_LOGIN         =  2,            //解冻玩家登录限制
    ID_GM_OFFICE_SUB_FREEZE_SPEAK           =  3,            //以天为单位冻结玩家发言
    ID_GM_OFFICE_SUB_UNFREEZE_SPEAK         =  4,            //解冻玩家发言限制
    ID_GM_OFFICE_SUB_FREEZE_GOLD            =  5,            //以天为单位冻结使用金币
    ID_GM_OFFICE_SUB_UNFREEZE_GOLD          =  6,            //解冻玩家使用金币限制
    ID_GM_OFFICE_SUB_FREEZE_SILVER          =  7,            //以天为单位冻结使用银币
    ID_GM_OFFICE_SUB_UNFREEZE_SILVER        =  8,            //解冻玩家使用银币限制
    ID_GM_OFFICE_SUB_FREEZE_BAG_STORGE      =  9,            //以天为单位冻结背包和仓库
    ID_GM_OFFICE_SUB_UNFREEZE_BAG_STORGE    = 10,            //解冻玩家背包和仓库限制
    ID_GM_OFFICE_SUB_SEND_ROLE_GIFT         = 11,            //发送礼包给玩家
    ID_GM_OFFICE_SUB_SEND_SYS_NOTICE        = 12,            //发送系统公告
    ID_GM_OFFICE_SUB_SYS_STOP_NOTICE        = 13,            //系统停机维护公告
    ID_GM_OFFICE_SUB_REPAIR_ROLE_HUNLI      = 14,            //修复角色魂力数据
    ID_GM_OFFICE_SUB_PULL_ALL_EQUIP         = 15,            //拉取玩家的装备数据
    ID_GM_OFFICE_SUB_GET_SYS_DATA           = 16,            //获取在线和注册
    ID_GM_OFFICE_SUB_GET_ROLE_BY_GID        = 17,            //通过GID获取角色信息
    ID_GM_OFFICE_SUB_GET_ROLE_BY_ROLENAME   = 18,            //通过昵称获取角色信息
    ID_GM_OFFICE_SUB_GET_ROLE_BY_USERTOKEN  = 19,            //通过OPENID获取角色信息
    ID_GM_OFFICE_SUB_SEND_BATCH_GIFTS       = 20,            //批量发送礼包
    ID_GM_OFFICE_SUB_SET_VIP_LEVEL          = 21,            //设置VIP等级
    ID_GM_OFFICE_SUB_STOP_OPEN_REGIST       = 22,            //设置服务器停止开放注册
    ID_GM_OFFICE_SUB_STOP_CREATE_CLAN       = 23,            //设置服务器停止创建家族
    //ID_GM_OFFICE_SUB_RESET_ZONE_OPEN_TIME   = 24,            //重置开服时间并重启
    ID_GM_OFFICE_SUB_TRIGGER_BUY_GOODS      = 24,            //外网模拟充值
};

//MsgTips type类型 统一在这里标识
enum ENUM_TIPS_TYPE
{
    TIPS_ACT_LIST = 10,
    TIPS_MAGIC_DOOR_BONUS = 50,
    TIPS_MAGIC_DOOR_CLOSE = 51,
    TIPS_WORLD_BOSS_BONUS = 52,
    TIPS_ACADEMY_BOSS_BONUS = 53,
    TIPS_CLAN_ADD_ITEM = 54,
    TIPS_EQUIP_FULL = 55,
    TIPS_MALL_NEW_GOODS = 63,  //商城新增物品提示
    TIPS_WORLD_BOSS_ACT_OPEN = 1019,
    TIPS_WORLD_BOSS_FIFTY = 1020,
    TIPS_WORLD_BOSS_RANK = 1021,
    TIPS_WORLD_BOSS_KILL_BOSS = 1022,
    TIPS_ACADEMY_BOSS_ACT_OPEN = 1023,
    TIPS_ACADEMY_BOSS_KILL_FIRST = 1024,
    TIPS_ACADEMY_BOSS_KILL_SELF = 1025,//本学院玩家击杀学院使者
    TIPS_ACADEMY_BOSS_KILL_OTHER = 1026,//其他学院玩家击杀学院使者
    TIPS_ENEMY_ATK_CITY_OPEN = 1028,
    TIPS_AUCTION_FINAL_OPEN = 1041,
    TIPS_SYSTEM_STOP_NOTICE = 1059,
    TIPS_SEND_SYSTEM_NOTICE = 1060,
    TIPS_ACADEMY_FOOTBOY_KILL_SELF = 1062,//本学院玩家击杀学院侍从
    TIPS_ACADEMY_FOOTBOY_KILL_OTHER = 1063,//其他学院玩家击杀学院侍从
    TIPS_ACADEMY_BOSS_FIFTY_SELF = 1064,//本学院玩家击杀学院使者50%伤害
    TIPS_ACADEMY_BOSS_FIFTY_OTHER = 1065,//其他学院玩家击杀学院使者50%伤害
    TIPS_FIGHTEND_WINNING_STREAK = 1076,//一战到底玩家获得3连胜

    TIPS_FIGHTEND_REVER_WINNING_STREAK = 1077,//一战到底玩家获得逆转3连胜

    TIPS_FASHION_MASTER_LEVEL = 1088,//时装大师跑马灯

    TIPS_TOTAL_CHARGE_STAGE_ONE = 1047, //累计充值跑马灯--任意符石
    TIPS_TOTAL_CHARGE_STAGE_TWO = 1098, //累计充值跑马灯--500符石
    TIPS_TOTAL_CHARGE_STAGE_THR = 1099, //累计充值跑马灯--2000符石
    TIPS_TOTAL_CHARGE_STAGE_FTH = 1100, //累计充值跑马灯--5000符石
    TIPS_TOTAL_CHARGE_STAGE_FIF = 1101, //累计充值跑马灯--10000符石
    TIPS_TOTAL_CHARGE_STAGE_SIX = 1102, //累计充值跑马灯--20000符石
    TIPS_TOTAL_CHARGE_STAGE_SEV = 1103, //累计充值跑马灯--50000符石
};

/**
* 响应的结果值.
* 该结构既是其他协议的一部分, 也是一条单独的协议
*/
class CResult: public CTCodeObject
{
public:
    int iResultID;  // 0表示正确
    CTSizeString<EMAX_RESULTMSG> szResultMsg;
};

BEGIN_CODE_CONVERT(CResult)
CODE_CONVERT(iResultID)
CODE_CONVERT(szResultMsg)
END_CODE_CONVERT(CResult)

class CReqSQL: public CTCodeObject
{
private:
    int m_iDataLen;
public:
    CTSizeString<EMAX_SQLLEN> stSQL;
    CTCodeMemory stSQLMen;

    CReqSQL()
        :m_iDataLen(0), stSQLMen(stSQL.GetBuffer(), stSQL.GetBufferLen(), m_iDataLen)
    {
    }

    int Init()
    {
        m_iDataLen = 0;
        stSQLMen.Init(stSQL.GetBuffer(), stSQL.GetBufferLen());
        return 0;
    }

    int Remove(int iLen)
    {
        if (iLen > m_iDataLen)
        {
            return -1;
        }
        else if (iLen < m_iDataLen) // 优化
        {
            memmove(stSQL.GetBuffer(), stSQL.GetBuffer() + iLen, m_iDataLen - iLen);
        }

        m_iDataLen -= iLen;
        return 0;
    }

    char *GetSqlBuffer()
    {
        return stSQLMen.GetBuffer();
    }

    int GetFreeSqlLen()
    {
        return stSQLMen.GetBufferLen() - stSQLMen.GetDataLen();
    }

    char* GetFreeSqlBuffer()
    {
        return stSQLMen.GetBuffer() + m_iDataLen;
    }

    int Append(int iLen)
    {
        m_iDataLen += iLen;
        return m_iDataLen;
    }

    int Set(const char* szFormat, ...)
    {
        m_iDataLen = 0;
        va_list ap;
        va_start(ap, szFormat);
        int iRet = VSet(szFormat, ap);
        va_end(ap);
        return iRet;
    }

    int VSet(const char * szFormat, va_list ap)
    {
        if (!szFormat)
        {
            return -1;
        }

        int iRet = ct_vsnprintf(stSQLMen.GetBuffer(), stSQLMen.GetBufferLen(), szFormat, ap);
        if (iRet < 0)
        {
            return -1;
        }

        m_iDataLen += iRet;
        return iRet;
    }

    int Cat(const char* szFormat, ...)
    {
        va_list ap;
        va_start(ap, szFormat);
        int iRet = VCat(szFormat, ap);
        va_end(ap);
        return iRet;
    }

    int VCat(const char* szFormat, va_list ap)
    {
        if (!szFormat)
        {
            return -1;
        }

        int iMaxLen = EMAX_SQLLEN - stSQLMen.GetDataLen();
        if (iMaxLen <= 0)
        {
            return -1;
        }

        int iRet = ct_vsnprintf(stSQLMen.GetBuffer() + stSQLMen.GetDataLen(), iMaxLen, szFormat, ap);
        if (iRet < 0)
        {
            return -1;
        }

        m_iDataLen += iRet;
        iRet = m_iDataLen;
        return iRet;
    }
};

BEGIN_CODE_CONVERT(CReqSQL)
CODE_CONVERT(stSQLMen)
END_CODE_CONVERT(CReqSQL)

//apisvr -> mpsvr(tencent api)
class CReqTencentApi : public CTCodeObject
{
public:
    CReqTencentApi()
        :_ucApiType(0)
    {
        
    }

    enum
    {
        OPEN_API  = 0,      //平台接口
        COMPASS = 1,        //罗盘
    };

    CTSizeString<50> _szApiName;        //比如:  /v3/user/get_info 
    CTLib::CTKeyValue _stKeyValue;      //请求参数
    unsigned char _ucApiType;           //api类型 1: open api 2: 罗盘
};
BEGIN_CODE_CONVERT(CReqTencentApi)
CODE_CONVERT(_szApiName)
CODE_CONVERT(_stKeyValue)
CODE_CONVERT(_ucApiType)
END_CODE_CONVERT(CReqTencentApi)

class CAnsTencentApi : public CTCodeObject
{
public:
    CResult _stResult;
    CTLib::CTKeyValue _stKeyValue;      //响应参数
};
BEGIN_CODE_CONVERT(CAnsTencentApi)
CODE_CONVERT(_stResult)
CODE_CONVERT(_stKeyValue)
END_CODE_CONVERT(CAnsTencentApi)

//mainsvr -> apisvr (ID_MAINAPI_TAPI)
class CReqApi : public CTCodeObject
{
public:
    CReqApi()
        :_ucApiType(0)
    {

    }

    enum  //请求类型
    {
        API_NULL = 0,
        API_TENCENT = 1,
    };

    unsigned char _ucReqType;               //请求类型

    CTSizeString<50> _szTApiName;               //tencent api 用， 比如:  /v3/user/get_info
    CTLib::CTKeyValue _stTApiKeyValue;          //tencent api 用, 请求参数
    unsigned char _ucApiType;                   //tencent api 用， 详细的接口类型
};
BEGIN_CODE_CONVERT(CReqApi)
CODE_CONVERT(_ucReqType)
CODE_CONVERT(_szTApiName)
CODE_CONVERT(_stTApiKeyValue)
CODE_CONVERT(_ucApiType)
END_CODE_CONVERT(CReqApi)

class CAnsApi : public CTCodeObject
{
public:
    CResult _stResult;
    unsigned char _ucReqType;               //请求类型

    CTLib::CTKeyValue _stTApiKeyValue;      //tencent api 用 响应参数
};
BEGIN_CODE_CONVERT(CAnsApi)
CODE_CONVERT(_stResult)
CODE_CONVERT(_ucReqType)
CODE_CONVERT(_stTApiKeyValue)
END_CODE_CONVERT(CAnsApi)

/*
*数据更新命令(ID_MAINDB_UPDATEDATA)
*main->db
*/
class CReqUpdateData : public CTCodeObject
{
public:
    //主键
    CVarObjectKey  m_stKey;
    //更新次数
    unsigned int m_uiSwapCount;
    //更新数据信息
    int iDataLen;

    int m_iOpType;
    //数据
    char * pszData;
};
BEGIN_CODE_CONVERT(CReqUpdateData)
CODE_CONVERT(m_stKey)
CODE_CONVERT(m_uiSwapCount)
CODE_CONVERT(iDataLen)
CODE_CONVERT(m_iOpType)
END_CODE_CONVERT(CReqUpdateData)

class CAnsUpdateData: public CTCodeObject
{
public:
    CResult stResult;
    //更新数据key
    CVarObjectKey m_stKey;
};
BEGIN_CODE_CONVERT(CAnsUpdateData)
CODE_CONVERT(stResult)
CODE_CONVERT(m_stKey)
END_CODE_CONVERT(CAnsUpdateData)

/*
*数据查询(ID_MAINDB_SELECTDATA)
*main->db
*/
class CReqSelectData : public CTCodeObject
{
public:
    char           m_ucCheckUpdateMgr;
    //主键
    CVarObjectKey  m_stKey;

    /*
    //SQL(可以不设置)
    CTSizeString<EMAX_SQLLEN> m_szSQL;
    */
};
BEGIN_CODE_CONVERT(CReqSelectData)
CODE_CONVERT(m_ucCheckUpdateMgr)
CODE_CONVERT(m_stKey)
//CODE_CONVERT(m_szSQL)
END_CODE_CONVERT(CReqSelectData)

class CAnsSelectData: public CTCodeObject
{
public:
    CResult stResult;

    //数据
    int iDataLen;
    char* pszData;
};
BEGIN_CODE_CONVERT(CAnsSelectData)
CODE_CONVERT(stResult)
CODE_CONVERT(iDataLen)
END_CODE_CONVERT(CAnsSelectData)


#endif //__COMMH_MSG_H__

